﻿@using X.PagedList;
@using X.PagedList.Mvc.Core;
@using X.PagedList.Mvc.Common;
@using FwProject.Restaurant.Dto
@model IPagedList<RestaurantOutputDto>
@{
    Layout = null;
    int i = 0;
    if (Model.Count > 0)
    {
        if (Model.PageNumber != 1)
        {

            i = (Model.PageNumber - 1) * Model.PageSize;
        }
    }
}
<div style="max-height:600px;overflow-y:scroll;">
    <table class="table table-bordered table-hover tree">
        <thead>
            <tr>
                <th class="collapsed"></th>
                <th style="width:45px">序号</th>
                <th>餐厅名称</th>
                <th>餐厅地址</th>
                <th>注册时间</th>
                <th>餐厅联系人</th>
                <th>餐厅手机</th>
                <th>收费方式</th>
                <th>结算方式</th>
                <th>结算周期</th>
                <th>配送司机</th>
                <th>停用标志</th>
                <th>押金金额</th>
                <th>收取押金日期</th>
                <th style="width:185px;">操作</th>
            </tr>
        </thead>
        <tbody>
            @if (Model.Count == 0)
            {
                <tr><td class="text-center" colspan="15">暂无餐厅信息</td></tr>
            }
            else
            {
                foreach (var item in Model)
                {
                    i++;
                    <tr data-value="@item.Id">
                        <td class="collapsed"><i class="fa fa-plus-square-o" data-id="@item.Id"></i></td>
                        <td>@i</td>
                        <td>@item.RestaurantName</td>
                        <td>@item.RestaurantAddress</td>
                        <td>@item.CreationTime.ToString("yyyy-MM-dd")</td>
                        @*<td>@(item.RestaurantContacts.Count() > 0 ? item.RestaurantContacts.First() : "")</td>
                            <td>@(item.RestaurantPhone.Count() > 0 ? item.RestaurantPhone.First() : "")</td>*@
                        <td>@item.RestaurantContact</td>
                        <td>@item.Mobile</td>
                        <td>@item.ChargeWay</td>
                        <td>@item.BalanceWay</td>
                        <td>@item.BalanceCycle</td>
                        <td>@item.DriverName</td>
                        <td>@Html.Raw(item.IsDiscontinuation ? "<span style='color:red'>是</span>" : "否")</td>
                        <td>@item.Deposit.ToString("N")</td>
                        <td>@(item.DepositDate.HasValue ? item.DepositDate.Value.ToString("yyyy-MM-dd") : "")</td>
                        <td>
                            <button class="btn btn-success btn-xs" onclick="ModifyRestaurant('@item.Id')"><i class="fa fa-edit"></i>编辑</button>
                            <button class="btn btn-danger btn-xs" data-toggle="modal" data-target="#modal_del" data-url="@Url.Action("DeleteRestaurant", new { id = item.Id })"><i class="fa fa-times"></i>删除</button>
                            <a class="btn btn-info btn-xs" href="/QRCoder/Index/@item.Id" target="_blank"><i class="glyphicon glyphicon-qrcode"></i>二维码</a>
                        </td>
                    </tr>
                    <tr data-selectable="false" class="tb-child hidden">
                        <td colspan="13">
                            <div class="row m-b-lg">
                                <div class="col-sm-12" style="width:100%">
                                    <div class="tabs-container">
                                        <div class="tabs-left">
                                            <div class="tab-content ">
                                                <div class="tab-pane active">
                                                    <div class="panel-body" style="width:100%; margin-left:0;padding-top:0;">
                                                        <div class="ibox-title" style="border-style:none;padding:15px;">
                                                            <h5>配送型号</h5>
                                                            <div class="ibox-tools">
                                                                <button class="btn btn-primary btn-xs" data-id="@item.Id" data-toggle="modal" data-target="#modal_ajax" data-url="@Url.Action("Create","RestaurantTypeNumber",new { id=item.Id })"><i class="fa fa-plus"></i>添加配送型号</button>
                                                            </div>
                                                        </div>
                                                        <table class="table table-bordered table-hover table-rowselected table-rowselected">
                                                            <thead>
                                                                <tr>
                                                                    <th>名称</th>
                                                                    <th>单位</th>
                                                                    <th>数量</th>
                                                                    <th>单价（套）</th>
                                                                    <th>描述</th>
                                                                    <th style="width:120px;">操作</th>
                                                                </tr>
                                                            </thead>
                                                            <tbody class="tb_tbody"></tbody>
                                                        </table>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </td>
                    </tr>
                }
            }
        </tbody>
    </table>

</div>
<div class="row pagedinfo">
    <div class="col-sm-5">
        共 @Model.TotalItemCount 条，
        <select class="form-control" id="pageSize" style="width:70px;display:initial">
            @for (int z = 10; z < 100; z = z + 10)
            {
                if (z == Model.PageSize)
                {
                    <option selected value="@z">@z</option>
                }
                else
                {
                    <option value="@z">@z</option>
                }
            }
        </select>
        @*@Model.PageSize*@ 条/页 当前第 @Model.PageNumber/@Model.PageCount 页
    </div>
    <div class="col-sm-7">
        <input type="hidden" id="pageurl" value="&keyword=@(Context.Request.Query["keyword"])&DriverId=@(Context.Request.Query["DriverId"])" />
        @Html.PagedListPager(Model, page => Url.Action("Index", new { id = page, size = Context.Request.Query["size"], keyword = Context.Request.Query["keyword"], factoryid = Context.Request.Query["factoryid"], DriverId = Context.Request.Query["DriverId"] }), PagedListRenderOptions.EnableUnobtrusiveAjaxReplacing(new AjaxOptions() { AllowCache = false, HttpMethod = "Get", UpdateTargetId = "data_list", OnSuccess = "AjaxSuccessCallback", OnBegin = "AjaxBegin" }))
    </div>
</div>